home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Celestin Apprentice 5
/
Apprentice-Release5.iso
/
Source Code
/
By the Book
/
Mac C Primer V2
/
6.1 - MyStarter
/
CStarterPane.c
< prev
next >
Wrap
Text File
|
1992-04-10
|
2KB
|
104 lines
/************************************************************/
/* */
/* CStarterPane Code from Chapter Six of */
/* */
/* *** The Macintosh Programming Primer *** */
/* */
/* Copyright 1990, Dave Mark */
/* */
/* This program demonstrates specific Mac programming */
/* techniques. */
/* */
/************************************************************/
#include "CStarterPane.h"
#include "CDragPane.h"
#include "CMouse.h"
/**************************************** IStarterPane */
void CStarterPane::IStarterPane( CView *anEnclosure, CBureaucrat *aSupervisor,
short aWidth, short aHeight,
short aHEncl, short aVEncl,
SizingOption aHSizing, SizingOption aVSizing )
{
CPanorama::IPanorama( anEnclosure, aSupervisor,
aWidth, aHeight,
aHEncl, aVEncl,
aHSizing, aVSizing );
GetDateTime( (unsigned long *)&randSeed );
SetWantsClicks( TRUE );
}
/******************************** DoClick *********/
void CStarterPane::DoClick( Point hitPt, short modifierKeys, long when )
{
int width, height, patNum;
CDragPane *myDragPane;
width = Randomize( MAX_PANE_SIZE );
height = Randomize( MAX_PANE_SIZE );
patNum = Randomize( NUM_PATS );
myDragPane = new( CDragPane );
myDragPane->IDragPane( hitPt, height, width,
patNum, this, this );
}
/******************************** AdjustCursor *********/
void CStarterPane::AdjustCursor( Point where, RgnHandle mouseRgn )
{
SetCursor( *GetCursor( plusCursor ) );
}
/******************************** DoDrag *********/
void CStarterPane::DoDrag( int objWidth, int objHeight,
Point hitPt, Rect startLocation, Rect *endLocation )
{
CMouse *aMouseTask;
LongRect boundsRect;
Point p;
LongPt longP;
gIsScrolling = TRUE;
boundsRect = bounds;
aMouseTask = new( CMouse );
aMouseTask->IMouse( NO_UNDO_STRING, objWidth,
objHeight, hitPt, startLocation, this );
Prepare();
GetMouse( &p );
QDToLongPt( p, &longP );
TrackMouse( aMouseTask, &longP, &boundsRect );
gIsScrolling = FALSE;
aMouseTask->GetLocation(endLocation); /* Update endLocation */
Refresh();
}
/******************************** Randomize *********/
Randomize( int range )
{
long rawResult;
rawResult = Random();
if ( rawResult < 0 ) rawResult *= -1;
return( (rawResult * range) / 32768 );
}